const app = getApp();
Page({
    /**
     * 页面的初始数据
     */
    data: {
        // 请求数组的初始变量
        // array: [{thing:'xuanzhi.jpg',name:'御宝阁旗舰店'},{thing:'hangzhoutuanshan.jpg',name:'王星记旗舰店'},{thing:'huzhoumaobi.jpg',name:'六品堂旗舰店'},{thing:'xianglu.jpg',name:'时匠者旗舰店'},{thing:'jianzhi.jpg',name:'御祺轩旗舰店'},{thing:'chayeguan.jpg',name:'鼎艺旗舰店'},{thing:'laranbeidian.jpg',name:'水家坊旗舰店'},{thing:'xiangnang.jpg',name:'江盏旗舰店'}],
        array:[],
        height: 0,
        background: ['https://api.hiehie.top:6001/images/diaoke.jpg', 'https://api.hiehie.top:6001/images/weidiao.jpg', 'https://api.hiehie.top:6001/images/yu.jpg'],
        indicatorDots: true,
        indicatorColor:'rgba(255,255,255,0.8)',
        vertical: false,
        autoplay: true,
        interval: 2000,
        duration: 500,
        circular:true
    },
    changeIndicatorDots() {
        this.setData({
            indicatorDots: !this.data.indicatorDots
        })
    },

    changeAutoplay() {
        this.setData({
            autoplay: !this.data.autoplay
        })
    },

    intervalChange(e) {
        this.setData({
            interval: e.detail.value
        })
    },

    durationChange(e) {
        this.setData({
            duration: e.detail.value
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        wx.getSystemInfo({
            success: (result) => {
                // console.log(result)
                this.setData({
                    height: result.windowHeight,
                });
            },
        });
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        // 请求数据
        wx.request({
            url: `${app.globalData.url}/content`,
            dataType: "json",
            method: "GET",
            header: {
                "content-type": "application/json",
            },
            success: (res) => {
                console.log(res);
                this.setData({
                    array: res.data,
                    // 将获取到的数据传给初始化的变量，在后端渲染
                });
            },
        });
    },


    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {},

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {},
});